<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- 게시물 수정 권한에 대한 상세 로직 설정 필요.
	 게시물 수정 권한을 받았을시 수정할수있는 범위 설정도 상의 필요
 -->
 
<script type="text/javascript">

$(function(){
	 $.ajax({
			type:"post",
			url:"${initParam.root}auction/findByCategory.do",
			datatype:"json",
			success:function(data){	
				 var BigClassList="<option value='${vo.bcvo.bigClassNo}'>--${vo.bcvo.bigClassName}--</option>";
				 	$.each(data, function(index, value){
									BigClassList+="<option value='"+value.bigClassNo+"'>"+value.bigClassName+"</option>";	
					});						
					$("#auctionUpdateView select[name=selBigClass]").html(BigClassList); 
			}//success
		});//ajax		
		$.ajax({
			type:"post",
			url:"${initParam.root}auction/getSmallClassList.do",
			datatype:"json",
			data:"bigClass=${vo.bcvo.bigClassNo}",
			success:function(data){	
				var smallClassList="<option value='${vo.scvo.smallClassNo}'>--${vo.scvo.smallClassName}--</option>";
				  	 
				$.each(data, function(index, value){
					smallClassList+="<option value='"+value.smallClassNo+"'>"+value.smallClassName+"</option>";
				});						
				$("#auctionUpdateView select[name=selSmallClass]").html(smallClassList); 
			}//success
		});//ajax
		 $("#auctionUpdateView select[name=selBigClass]").change(function(){		
		    		var bigClass = $("#auctionUpdateView select[name=selBigClass]").val();
					$.ajax({
							type:"post",
							url:"${initParam.root}auction/getSmallClassList.do",
							datatype:"json",
							data:"bigClass="+bigClass,
							success:function(data){						
								var smallClassList="<option value=''>--소분류--</option>"; 	 
								$.each(data, function(index, value){
									smallClassList+="<option value='"+value.smallClassNo+"'>"+value.smallClassName+"</option>";
								});						
								$("#auctionRegisterView select[name=selSmallClass]").html(smallClassList); 
							}//success
						});//ajax
			});//change
			
	$("#auctionUpdateView select[name=selSmallClass]").change(function(){
		var smallClassNo = $("#auctionUpdateView select[name=selSmallClass]").val();
		alert("smallClassNo "+smallClassNo);
		$("#auctionUpdateView :input[name=smallClassNo]").val(smallClassNo);
	});//change

		$("#auctionUpdateView").submit(function(){		
			 if($("#selBigClass").val()==""){
				  alert("카테고리 선택 ");
				  return false;
			 }else if($("#selSmallClass").val()==""){
				 alert("소분류 선택 ");
				  return false;
			 }else if($("#boardTitle").val()==""){
				 alert("제목 입력");
				  return false;
			 }  else if($("#boardContent").val()==""){
					 alert("내용 입력");
					return false;
			 }
		});	
});	

</script>

<form id="auctionUpdateView" action="${initParam.root}auction/auctionUpdate.do" method="post">
<input type="hidden" id="smallClassNo" name="smallClassNo" value="${vo.scvo.smallClassNo}">
<input type="hidden" id="boardNo" name="boardNo" value="${vo.avo.boardNo}">
<input type="hidden" id="memberNo" name="memberNo" value="${vo.mvo.memberNo}">
<input type="hidden" id="timePosted" name="timePosted" value="${vo.avo.timePosted}">
<table border="1">
<tr>
	<td>카테고리</td>
		<td>
			<select  id="selBigClass" name="selBigClass">					
			</select>			
			<select id="selSmallClass" name="selSmallClass">						
			</select>
			<input type="hidden" id="smallClassNo" name="smallClassNo">
		</td>
</tr>
<tr>
		<td>게시물 제목</td> 
		<td><input type="text" name="boardTitle" id="boardTitle" value="${vo.avo.boardTitle}" ></td>
</tr>
<tr>
	<td>내용</td>
	<td><textarea rows="20" cols="50" name="boardContent" id="boardContent">${vo.avo.boardContent}</textarea></td>
</tr>
<tr>
	<td>경매가</td>
	<td><input readonly type="text" id="auctionPrice" name="auctionPrice" value="${vo.avo.auctionPrice}"></td>
</tr>
<tr>	
	<td>경매시간</td>
	<td>
		<select id="auctionTime" name="auctionTime" >
		<c:choose>
		<c:when test="${vo.avo.auctionTime==1}">
			<option disabled="disabled" value="1" selected="selected">1일</option>
			<option disabled="disabled" value="3">3일</option>
			<option disabled="disabled" value="7">7일</option>
		</c:when>
		<c:when test="${vo.avo.auctionTime==3}">
			<option disabled="disabled"  value="1" >1일</option>
			<option disabled="disabled" value="3"  selected="selected">3일</option>
			<option disabled="disabled" value="7">7일</option>
		</c:when>
		<c:otherwise>
			<option disabled="disabled"  value="1" >1일</option>
			<option disabled="disabled" value="3" >3일</option>
			<option disabled="disabled" value="7" selected="selected">7일</option>
		</c:otherwise>
		</c:choose>
		</select>
	</td>
</tr>
<tr>
	<td>즉시구매가</td>
	<td><input readonly type="text" id="buyPrice" name="buyPrice" value="${vo.avo.buyPrice}"></td>
</tr>
<tr>
	<td>수량</td>
	<td><input readonly type="text" id="quantity" name="quantity" value="${vo.avo.quantity}"></td>
	
</tr>
<tr>
	<td colspan="2"><input type="submit" value="수정"></td>
</tr>


</table>
</form>